﻿using Cloud.BLL;
using Cloud.Model;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Three_Managerment_P0452_List_yq : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            if (!IsPostBack)
            {
                bind2();
                bind3();
                //this.bianhao.DataSource = ProblemManager.Bm1_blz(((USER_INFO)Session["users"]).DEPARTMENT);
                //this.bianhao.DataTextField = "appealid";
                //this.bianhao.DataValueField = "id";
                //this.bianhao.DataBind();
                //this.bianhao.Items.Insert(0, new ListItem("--请选择--", "0"));
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    protected void AspNetPager2_PageChanged(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            bind2();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }


    public void bind2()
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
            SqlCommand cmd = new SqlCommand("SELECT * FROM yqsq WHERE bm0_type=0 OR bm0_type=1", connection);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            AspNetPager2.PageSize = 10;//设置分页大小 
            AspNetPager2.RecordCount = YqsqManager.bm2_yq_list(((USER_INFO)Session["users"]).DEPARTMENT).Count;//设置总数据条数 
            sda.Fill(ds, AspNetPager2.PageSize * (AspNetPager2.CurrentPageIndex - 1), AspNetPager2.PageSize, "yqsq");//固定不变的 
            repeater2.DataSource = ds.Tables["yqsq"];
            repeater2.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
    protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        try
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep1") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                int typeid = Convert.ToInt32(rowv["sjid"]); //获取填充子类的id 
                IList<Problem> sou = new List<Problem>();
                sou.Add(ProblemManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep2") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                int typeid = Convert.ToInt32(rowv["sjid"]); //获取填充子类的id 
                IList<Problem> sou = new List<Problem>();
                sou.Add(ProblemManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep3") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                int typeid = Convert.ToInt32(rowv["sjid"]); //获取填充子类的id 
                IList<Problem> sou = new List<Problem>();
                sou.Add(ProblemManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }


            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep5") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                string typeid = Convert.ToString(rowv["zrdwid"]); //获取填充子类的id 
                IList<ZS_TYPEINFO> sou = new List<ZS_TYPEINFO>();
                sou.Add(ZS_TYPEINFOManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep6") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                string typeid = Convert.ToString(rowv["bldwid"]); //获取填充子类的id 
                IList<DW> sou = new List<DW>();
                sou.Add(DWManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    //事件状态
    public string sjzt(int i)
    {
        try
        {
            String zts = "";
            if (i == 0)
            {
                zts = "待办理";
            }
            else if (i == 1)
            {
                zts = "办理中";
            }
            else if (i == 2)
            {
                zts = "已办理";
            }
            else if (i == 3)
            {
                zts = "已办结";
            }
            else if (i == 4)
            {
                zts = "直办";
            }
            return zts;
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return "";
        }

    }


    protected void repeater3_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        try
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep1") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                int typeid = Convert.ToInt32(rowv["sjid"]); //获取填充子类的id 
                IList<Problem> sou = new List<Problem>();
                sou.Add(ProblemManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep2") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                int typeid = Convert.ToInt32(rowv["sjid"]); //获取填充子类的id 
                IList<Problem> sou = new List<Problem>();
                sou.Add(ProblemManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep3") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                int typeid = Convert.ToInt32(rowv["sjid"]); //获取填充子类的id 
                IList<Problem> sou = new List<Problem>();
                sou.Add(ProblemManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }


            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep5") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                string typeid = Convert.ToString(rowv["zrdwid"]); //获取填充子类的id 
                IList<ZS_TYPEINFO> sou = new List<ZS_TYPEINFO>();
                sou.Add(ZS_TYPEINFOManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep6") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                string typeid = Convert.ToString(rowv["bldwid"]); //获取填充子类的id 
                IList<DW> sou = new List<DW>();
                sou.Add(DWManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    public void bind3()
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
            SqlCommand cmd = new SqlCommand("SELECT * FROM yqsq WHERE bm0_type=9 AND bm1_type=0 ", connection);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            AspNetPager3.PageSize = 10;//设置分页大小 
            AspNetPager3.RecordCount = YqsqManager.bm2_yq_list(((USER_INFO)Session["users"]).DEPARTMENT).Count;//设置总数据条数 
            sda.Fill(ds, AspNetPager2.PageSize * (AspNetPager2.CurrentPageIndex - 1), AspNetPager2.PageSize, "yqsq");//固定不变的 
            repeater3.DataSource = ds.Tables["yqsq"];
            repeater3.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    protected void AspNetPager3_PageChanged(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            bind3();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    //延期至
    public string select_yqz(string i)
    {
        string s = "";
        try
        {
            Yqsq y = YqsqManager.select_Foridopen(i);
            return y.Times.ToString();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return s;
        }
    }
}